package com.athuahua.spzx.controller;

import com.athuahua.spzx.entity.Region;
import com.athuahua.spzx.service.RegionService;
import com.athuahua.spzx.utils.Result;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: huahua
 * @Date: 2024/8/26 0026
 * @Time: 17:35
 * @Description:
 */
@RestController
@RequestMapping("api/user/region")
@Slf4j
@Tag(name = "地址模块")
public class RegionController {
    @Resource
    private RegionService regionService;

    /**
     * 请求 URL:
     * http://localhost:8500/api/user/region/findByParentCode/0
     * 请求方法:
     * GET
     */
    @GetMapping("/findByParentCode/{parentCode}")
    public Result findByParentCode(@PathVariable("parentCode") String parentCode) {
        List<Region> regionList = regionService.selectByParentCode(parentCode);

        return Result.success(regionList);
    }

    @Value("${spzx.smscode}")
    private String smsCode;

    @GetMapping("test")
    public Result test(){
        return Result.success(smsCode);
    }

}
